﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRasta.DI;
using OpenRasta.OperationModel;
using OpenRasta.OperationModel.Interceptors;
using OpenRasta.Web;
using uREST.Core.Extensions;
using uREST.Core.Interceptors;

namespace uREST.Core.Attributes
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class UmbracoAuthorizeAttribute : InterceptorProviderAttribute
    {
        public string Applications { get; set; }

        public override IEnumerable<IOperationInterceptor> GetInterceptors(IOperation operation)
        {
            return new[] { new UmbracoAuthorizeInterceptor(DependencyManager.GetService<ICommunicationContext>(), Applications.TrimSplit()) };
        }
    }
}
